<?
include ('../config.php');

$id 	= 'id';
$vname 	= 'permissions'; 
$cid = $_REQUEST[$id];

$form = new form();
$form->table = "ACL";
$form->action = $config['submit_url'];
$form->include = array("usertype"=>array("type"=>"select","query"=>"select utypeid,name from utypes","id"=>"utypeid","v"=>"name"),
                       "Module"=>array("type"=>"select","query"=>"select moduleid,name from modules","id"=>"moduleid","v"=>"name"),
                       "allow"=>array("type"=>"cselect","query"=>array("0"=>"no","1"=>"Yes"),"id"=>"allow","v"=>"allow")
                
		       );


if(!$cid){
	$form->title 		= "Add new ".$vname;
	$form->submit 		= "Add ".$vname;
}else{
	$form->title 		= "Edit ".$vname;
	$form->submit 		= "Edit ".$vname;
	$form->index 		= $cid;
	$form->indexname	= $id;
	$form->Addnew		= array('url'=>$_SERVER['PHP_SELF'],'text'=>'Add New '.$vname);
}
$parse = $form->CreateForm();
echo $parse;

$view = new view();
//creating the view
$view->title 						= "Current defined ".$vname;
$view->query 						= "select ".$id.",u.name as bekh,m.name ,allow from ".$form->table." x  join utypes u on (x.utypeid = u.utypeid) join modules m on (m.moduleid = x.moduleid) ";
$view->properties['headers'] 		= array($vname.' ID'=>"","User type"=>"", "Module"=>"","allowed"=>"");
$view->properties['cols']			= '5';
$view->properties['editurl']		= $_SERVER['PHP_SELF'];
$view->properties['editparam']  	= array($id=>'##'.$id.'##');
$view->properties['deleteurl']		= $config['submit_url'];
$view->properties['deleteparam']	= array('index'=>'##'.$id.'##','indexname'=>$id,'submit'=>'DELETE','t'=>$form->table);
$parse = $view->CreateView();
echo $parse;
?>

<a href='users.php'>Manage users</a><BR>
<a href='utypes.php'>Manage user types</a><BR>
<a href='index.php'>Home</a>